package com.ling.rocketmq.configuration;

import com.ling.rocketmq.consumer.ConsumerFactory;
import com.ling.rocketmq.producer.MQProducerFactory;
import com.ling.rocketmq.properties.ConsumerProperties;
import com.ling.rocketmq.properties.ProducerProperties;
import com.ling.rocketmq.properties.RocketmqSrvProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

@Configurable
@EnableConfigurationProperties(
        {
                RocketmqSrvProperties.class,
                ProducerProperties.class,
                ConsumerProperties.class
        })
public class RocketmqAutoConfiguration {
    @Autowired
    private RocketmqSrvProperties rocketmqSrvProperties;
    @Autowired
    private ProducerProperties producerProperties;
    @Autowired
    private ConsumerProperties consumerProperties;


    @Bean
    public MQProducerFactory getProducerFactory() {
        return new MQProducerFactory(rocketmqSrvProperties, producerProperties);
    }

    @Bean
    public ConsumerFactory getConsumerFactory() {
        return new ConsumerFactory(rocketmqSrvProperties, consumerProperties);
    }


}